package com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Infor.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Infor.ItemBean.Infor;

import java.util.List;
import java.util.zip.Inflater;

public class rvInformationListAdapter extends RecyclerView.Adapter<rvInformationListAdapter.ViewHolder>{
    private List<Infor> mData;

    public rvInformationListAdapter(List<Infor> mData) {
        this.mData = mData;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_infor_list, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull rvInformationListAdapter.ViewHolder holder, int position) {
        holder.iv_icon.setImageResource(mData.get(position).getIcon());
        holder.tv_file_name.setText(mData.get(position).getTv_file_name());
        holder.tv_file_size.setText(mData.get(position).getTv_file_size());
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }
    static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_icon;
        TextView tv_file_name,tv_file_size;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_icon = itemView.findViewById(R.id.iv_icon);
            tv_file_name = itemView.findViewById(R.id.tv_file_name);
            tv_file_size = itemView.findViewById(R.id.tv_file_size);
        }
    }
}
